package com.byjh.app.service.impl;

import java.util.List;

import com.byjh.app.vo.ErrorSetVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.byjh.app.mapper.ErrorCollectSetMapper;
import com.byjh.app.domain.ErrorCollectSet;
import com.byjh.app.service.IErrorCollectSetService;

/**
 * 错题集Service业务层处理
 *
 * @author Dhq
 * @date 2025-02-27
 */
@Service
public class ErrorCollectSetServiceImpl implements IErrorCollectSetService {
    @Autowired
    private ErrorCollectSetMapper errorCollectSetMapper;

    /**
     * 查询错题集
     *
     * @param id 错题集主键
     * @return 错题集
     */
    @Override
    public ErrorCollectSet selectErrorSetById(Long id) {
        return errorCollectSetMapper.selectErrorSetById(id);
    }

    @Override
    public int selectErrorSetCount(Long userId, Integer type, String date) {
        return errorCollectSetMapper.selectErrorSetCount(userId, type, date);
    }

    /**
     * 查询错题集列表
     *
     * @return 错题集
     */
    @Override
    public List<ErrorSetVo> selectErrorSetList(Long userId, Integer type) {
        return errorCollectSetMapper.selectErrorSetList(userId, type);
    }


    /**
     * 是否收藏
     *
     * @param userId
     * @param questionId
     * @return
     */
    @Override
    public boolean isCollect(Long userId, Long questionId) {
        return errorCollectSetMapper.isCollect(userId, questionId);
    }


    /**
     * 新增错题集
     *
     * @param errorCollectSet 错题集
     * @return 结果
     */
    @Override
    public int insertErrorSet(ErrorCollectSet errorCollectSet) {
        return errorCollectSetMapper.insertErrorSet(errorCollectSet);
    }

    /**
     * 修改错题集
     *
     * @param errorCollectSet 错题集
     * @return 结果
     */
    @Override
    public int updateErrorSet(ErrorCollectSet errorCollectSet) {
        return errorCollectSetMapper.updateErrorSet(errorCollectSet);
    }

    /**
     * 批量删除错题集
     *
     * @param ids 需要删除的错题集主键
     * @return 结果
     */
    @Override
    public int deleteErrorSetByIds(Long[] ids) {
        return errorCollectSetMapper.deleteErrorSetByIds(ids);
    }

    /**
     * 删除错题集信息
     *
     * @param id 错题集主键
     * @return 结果
     */
    @Override
    public int deleteErrorSetById(Long id) {
        return errorCollectSetMapper.deleteErrorSetById(id);
    }


    /**
     * 取消收藏
     *
     * @param questionId
     * @param userId
     * @return
     */
    @Override
    public int deleteErrorSetByQuestionIdAndUserId(Long questionId, Long userId) {
        return errorCollectSetMapper.deleteErrorSetByQuestionIdAndUserId(questionId, userId);
    }


}
